/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.dengues.model.database.impl;

import org.dengues.model.database.DatabaseDiagram;
import org.dengues.model.database.DatabasePackage;
import org.dengues.model.database.DiagramChild;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Diagram Child</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getX <em>X</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getY <em>Y</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getWidth <em>Width</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getHeight <em>Height</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#getDbDiagram <em>Db Diagram</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.DiagramChildImpl#isSelected <em>Selected</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class DiagramChildImpl extends AbstractDBObjectImpl implements DiagramChild {
    /**
     * The default value of the '{@link #getX() <em>X</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getX()
     * @generated
     * @ordered
     */
    protected static final int X_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getX() <em>X</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getX()
     * @generated
     * @ordered
     */
    protected int x = X_EDEFAULT;

    /**
     * The default value of the '{@link #getY() <em>Y</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getY()
     * @generated
     * @ordered
     */
    protected static final int Y_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getY() <em>Y</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getY()
     * @generated
     * @ordered
     */
    protected int y = Y_EDEFAULT;

    /**
     * The default value of the '{@link #getWidth() <em>Width</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getWidth()
     * @generated
     * @ordered
     */
    protected static final int WIDTH_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getWidth() <em>Width</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getWidth()
     * @generated
     * @ordered
     */
    protected int width = WIDTH_EDEFAULT;

    /**
     * The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getHeight()
     * @generated
     * @ordered
     */
    protected static final int HEIGHT_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getHeight()
     * @generated
     * @ordered
     */
    protected int height = HEIGHT_EDEFAULT;

    /**
     * The default value of the '{@link #getId() <em>Id</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getId()
     * @generated
     * @ordered
     */
    protected static final String ID_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getId()
     * @generated
     * @ordered
     */
    protected String id = ID_EDEFAULT;

    /**
     * The default value of the '{@link #isSelected() <em>Selected</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #isSelected()
     * @generated
     * @ordered
     */
    protected static final boolean SELECTED_EDEFAULT = false;

    /**
     * The cached value of the '{@link #isSelected() <em>Selected</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #isSelected()
     * @generated
     * @ordered
     */
    protected boolean selected = SELECTED_EDEFAULT;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected DiagramChildImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected EClass eStaticClass() {
        return DatabasePackage.Literals.DIAGRAM_CHILD;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getX() {
        return x;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setX(int newX) {
        int oldX = x;
        x = newX;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__X, oldX, x));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getY() {
        return y;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setY(int newY) {
        int oldY = y;
        y = newY;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__Y, oldY, y));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getWidth() {
        return width;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setWidth(int newWidth) {
        int oldWidth = width;
        width = newWidth;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__WIDTH, oldWidth, width));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getHeight() {
        return height;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setHeight(int newHeight) {
        int oldHeight = height;
        height = newHeight;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__HEIGHT, oldHeight, height));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getId() {
        return id;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setId(String newId) {
        String oldId = id;
        id = newId;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__ID, oldId, id));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public DatabaseDiagram getDbDiagram() {
        if (eContainerFeatureID != DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM) return null;
        return (DatabaseDiagram)eContainer();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetDbDiagram(DatabaseDiagram newDbDiagram, NotificationChain msgs) {
        msgs = eBasicSetContainer((InternalEObject)newDbDiagram, DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM, msgs);
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setDbDiagram(DatabaseDiagram newDbDiagram) {
        if (newDbDiagram != eInternalContainer() || (eContainerFeatureID != DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM && newDbDiagram != null)) {
            if (EcoreUtil.isAncestor(this, newDbDiagram))
                throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
            NotificationChain msgs = null;
            if (eInternalContainer() != null)
                msgs = eBasicRemoveFromContainer(msgs);
            if (newDbDiagram != null)
                msgs = ((InternalEObject)newDbDiagram).eInverseAdd(this, DatabasePackage.DATABASE_DIAGRAM__DB_CHILDREN, DatabaseDiagram.class, msgs);
            msgs = basicSetDbDiagram(newDbDiagram, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM, newDbDiagram, newDbDiagram));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean isSelected() {
        return selected;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setSelected(boolean newSelected) {
        boolean oldSelected = selected;
        selected = newSelected;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.DIAGRAM_CHILD__SELECTED, oldSelected, selected));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                if (eInternalContainer() != null)
                    msgs = eBasicRemoveFromContainer(msgs);
                return basicSetDbDiagram((DatabaseDiagram)otherEnd, msgs);
        }
        return super.eInverseAdd(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                return basicSetDbDiagram(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
        switch (eContainerFeatureID) {
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                return eInternalContainer().eInverseRemove(this, DatabasePackage.DATABASE_DIAGRAM__DB_CHILDREN, DatabaseDiagram.class, msgs);
        }
        return super.eBasicRemoveFromContainerFeature(msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__X:
                return new Integer(getX());
            case DatabasePackage.DIAGRAM_CHILD__Y:
                return new Integer(getY());
            case DatabasePackage.DIAGRAM_CHILD__WIDTH:
                return new Integer(getWidth());
            case DatabasePackage.DIAGRAM_CHILD__HEIGHT:
                return new Integer(getHeight());
            case DatabasePackage.DIAGRAM_CHILD__ID:
                return getId();
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                return getDbDiagram();
            case DatabasePackage.DIAGRAM_CHILD__SELECTED:
                return isSelected() ? Boolean.TRUE : Boolean.FALSE;
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__X:
                setX(((Integer)newValue).intValue());
                return;
            case DatabasePackage.DIAGRAM_CHILD__Y:
                setY(((Integer)newValue).intValue());
                return;
            case DatabasePackage.DIAGRAM_CHILD__WIDTH:
                setWidth(((Integer)newValue).intValue());
                return;
            case DatabasePackage.DIAGRAM_CHILD__HEIGHT:
                setHeight(((Integer)newValue).intValue());
                return;
            case DatabasePackage.DIAGRAM_CHILD__ID:
                setId((String)newValue);
                return;
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                setDbDiagram((DatabaseDiagram)newValue);
                return;
            case DatabasePackage.DIAGRAM_CHILD__SELECTED:
                setSelected(((Boolean)newValue).booleanValue());
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void eUnset(int featureID) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__X:
                setX(X_EDEFAULT);
                return;
            case DatabasePackage.DIAGRAM_CHILD__Y:
                setY(Y_EDEFAULT);
                return;
            case DatabasePackage.DIAGRAM_CHILD__WIDTH:
                setWidth(WIDTH_EDEFAULT);
                return;
            case DatabasePackage.DIAGRAM_CHILD__HEIGHT:
                setHeight(HEIGHT_EDEFAULT);
                return;
            case DatabasePackage.DIAGRAM_CHILD__ID:
                setId(ID_EDEFAULT);
                return;
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                setDbDiagram((DatabaseDiagram)null);
                return;
            case DatabasePackage.DIAGRAM_CHILD__SELECTED:
                setSelected(SELECTED_EDEFAULT);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case DatabasePackage.DIAGRAM_CHILD__X:
                return x != X_EDEFAULT;
            case DatabasePackage.DIAGRAM_CHILD__Y:
                return y != Y_EDEFAULT;
            case DatabasePackage.DIAGRAM_CHILD__WIDTH:
                return width != WIDTH_EDEFAULT;
            case DatabasePackage.DIAGRAM_CHILD__HEIGHT:
                return height != HEIGHT_EDEFAULT;
            case DatabasePackage.DIAGRAM_CHILD__ID:
                return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
            case DatabasePackage.DIAGRAM_CHILD__DB_DIAGRAM:
                return getDbDiagram() != null;
            case DatabasePackage.DIAGRAM_CHILD__SELECTED:
                return selected != SELECTED_EDEFAULT;
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (x: ");
        result.append(x);
        result.append(", y: ");
        result.append(y);
        result.append(", width: ");
        result.append(width);
        result.append(", height: ");
        result.append(height);
        result.append(", id: ");
        result.append(id);
        result.append(", selected: ");
        result.append(selected);
        result.append(')');
        return result.toString();
    }

} //DiagramChildImpl
